package com.acme.bankapp.domain.bank;

import com.acme.bankapp.service.bank.ClientExistsException;

import java.util.LinkedList;
import java.util.List;

public class Bank {
    private final List<Client> clients = new LinkedList<Client>();

    public List<Client> getClients() {
        return clients;
    }

    public void addClient(Client client) throws ClientExistsException {
        for (Client bankClient : clients) {
            if (bankClient.getClientSalutation().equals(client.getClientSalutation())) {
                throw new ClientExistsException(client);
            }
        }
        clients.add(client);
    }
}